<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            border: 0;
            margin: 0;
        }
        .box{
            height: 100px;
            width: 100%;
            background-image: url(images/jd.png);
            position: relative;
        }
        .close-btn{
            position: absolute;
            right: 25px;
            top: 8px;
            width: 20px;
            height: 20px;
            border: 1px solid #000000;
            line-height: 20px;
            text-align: center; /*内容居中*/
            color: #ffffff;
            font-family: Arial, Helvetica, sans-serif; /* 3种字体 */
            cursor: pointer; /*鼠标 光标小手*/
        }
    </style>
</head>
<body>
    <div class="box">
        <i class="close-btn">x</i>
    </div>
    <script>
        // 1. 获取元素
        var box = document.querySelector('.box');
        var btn = document.querySelector('.close-btn');
        //2. 注册事件
        btn.onclick = function(){
            box.style.display = 'none'; /*display = 'none'; 隐藏的意思*/
        }
    </script>
</body>
</html>